var reverse = function(x) {
  var str = x.toString();
  var arr = str.split('');
  console.log(Number.isNaN(Number(arr[0])))
  if (Number.isNaN(Number(arr[0]))) {
    var symbolNum = arr[0];
    console.log(symbolNum)
    arr.shift()
    var str = reverseArr(arr).join('');
    var newStr = symbolNum + str;
    console.log(newStr)
    console.log(Number(newStr))
    return Number(newStr);

  }
  var str = reverseArr(arr).join('');
  return Number(str);

  function reverseArr(arr) {
    var len = arr.length;
    var newArr = []
    for (var i = len - 1; i >= 0; i--) {
      newArr.push(arr[i])
    }
    return newArr;
  }

};

reverse(-123)